package com.zcup.designer.construct.composite;

import java.util.ArrayList;
import java.util.List;

public class ConcreteComponent extends Component {
    private final List<Component> children = new ArrayList<>();

    public ConcreteComponent(String id) {
        super(id);
    }

    @Override
    void add(Component component) {
        children.add(component);
    }

    @Override
    void remove(Component component) {
        children.remove(component);
    }

    @Override
    void display(int depth) {
        System.out.println(getLine(depth) + getId());
        for (Component child : children) {
            child.display(depth + 2);
        }
    }
}
